package com.sxdz

import com.sxdz.controller.filter.CorsResponseFilter
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.context.embedded.FilterRegistrationBean
import org.springframework.boot.context.web.SpringBootServletInitializer
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.EnableWebMvc
/**
 * Created by zb on 2015/6/9.
 */

@CompileStatic
@TypeChecked
@EnableWebMvc
@Configuration //配置控制
@EnableAutoConfiguration  //启用自动配置
@ComponentScan
class ApplicationRun extends SpringBootServletInitializer{

    static void main(String[] args) throws Exception {
        SpringApplication.run ApplicationRun.class, args
    }

    /***  打war 包**/
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ApplicationRun.class);
    }


    @Bean
    public FilterRegistrationBean registration(CorsResponseFilter filter) {
        FilterRegistrationBean registration = new FilterRegistrationBean(filter);
        registration.setEnabled(true);
        return registration;
    }
}
